package com.ruoyi.custom.kami.utils;

import java.util.HashSet;
import java.util.Random;
import java.util.Set;

public class BuildKaMiTools {

    public static Set<String> buildKaimi(int length,int count) {
        //int length = 16;
       // int count = 10; // 指定生成的激活码个数
        Set<String> activationCodes = generateActivationCodes(length, count);
        System.out.println("生成的激活码：");
        for (String code : activationCodes) {
            System.out.println(code);
        }

        return activationCodes;
    }

    public static Set<String> generateActivationCodes(int length, int count) {
        String digits = "0123456789";
        Set<String> activationCodes = new HashSet<>();
        Random random = new Random();
        while (activationCodes.size() < count) {
            StringBuilder sb = new StringBuilder(length);
            for (int i = 0; i < length; i++) {
                int index = random.nextInt(digits.length());
                sb.append(digits.charAt(index));
            }
            activationCodes.add(sb.toString());
        }
        return activationCodes;
    }


}
